package com.example.xpvideo.service.serviceImpl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.xpvideo.context.PageContext;
import com.example.xpvideo.entity.LsShopApply;
import com.example.xpvideo.entity.PageResult;
import com.example.xpvideo.entity.Qualification;
import com.example.xpvideo.entity.ResponseResult;
import com.example.xpvideo.entity.req.PhpMerchantsApplyReq;
import com.example.xpvideo.entity.res.PHPMerchantsApplyListRes;
import com.example.xpvideo.exception.ErrorException;
import com.example.xpvideo.mapper.QualificationMapper;
import com.example.xpvideo.service.QualificationService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
 * 资质表(Qualification)Service层
 *
 * @author 杨丽辉
 * @since 2021-08-19 17:50:18
 */
@Service
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
public class QualificationServiceImpl implements QualificationService {
    @Autowired
    private QualificationMapper qualificationMapper;

    @Override
    public ResponseResult<PageResult<List<Qualification>>> list() throws ErrorException {

        int page = PageContext.getPage();
        int size = PageContext.getSize();



        PageHelper.startPage(page, size);
        List<Qualification> list = qualificationMapper.selectList(Wrappers.<Qualification>query());

        PageInfo pageInfo = new PageInfo<>(list);
        //当前页
        int pageNum = pageInfo.getPageNum();
        //总页数
        int pages = pageInfo.getPages();
        //当前页展示的数量
        int pageSize = pageInfo.getSize();
        //查询总数
        long count = pageInfo.getTotal();
        PageResult<List<Qualification>> listPageResult = new PageResult<>(count, pages,
                pageSize, pageNum,list);

        return ResponseResult.responseResult(0, listPageResult);

    }
}

